﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CLEXA.ClientTools.Collections
{
    public class ReadOnlyObservableDictionary<TKey, TValue> : IReadOnlyObservableDictionary<TKey, TValue>
    {
        private readonly IObservableDictionary<TKey, TValue> dictionary;

        public event ItemChangedHandler<TValue> ItemChanged
        {
            add { dictionary.ItemChanged += value; }
            remove { dictionary.ItemChanged -= value; }
        }

        public event ItemHandler<TValue> ItemRemoved
        {
            add { dictionary.ItemRemoved += value; }
            remove { dictionary.ItemRemoved -= value; }
        }

        public event ItemHandler<TValue> ItemAdded
        {
            add { dictionary.ItemAdded += value; }
            remove { dictionary.ItemAdded -= value; }
        }

        public TValue this[TKey key]
        {
            get
            {
                return dictionary[key];
            }
            set
            {
                dictionary[key] = value;
            }
        }

        public IEnumerable<TValue> Values
        {
            get { return dictionary.Values; }
        }

        public ReadOnlyObservableDictionary(IObservableDictionary<TKey, TValue> dictionary)
        {
            this.dictionary = dictionary;
        }
    }
}
